<template>
	<view class="">
		<view>
			<s-pull-scroll ref="pullScroll" :pullDown="pullDown" :enablePullDown="false" :pullUp="loadData" :back-top="true">
				<view class="mes-con">
					<view class="item row between" v-for="(item, index) in dataList" :key="index">
						<view class="item-left-icon">
							<image src="/static/img/xx1.png" mode="" class="left-icon" v-if="index % 3 == 0"></image>
							<image src="/static/img/xx2.png" mode="" class="left-icon" v-else-if="index % 3 == 1"></image>
							<image src="/static/img/xx3.png" mode="" class="left-icon" v-else></image>
							<view class="isRead" v-if="item.state == 0"></view>
						</view>
						<view class="fill">
							<view class="row between">
								<view class="item-title clamp">{{ item.title }}</view>
								<view class="item-right">{{ item.createDate }}</view>
							</view>
							<view class="item-txt">{{ item.content }}</view>
						</view>
					</view>
				</view>
			</s-pull-scroll>
		</view>
		<mix-loading v-if="isLoading"></mix-loading>
	</view>
</template>

<script>
export default {
	data() {
		return {
			dataList: []
		};
	},
	onLoad() {
		this.refresh();
	},
	methods: {
		pullDown(pullScroll) {
			setTimeout(() => {
				this.loadData(pullScroll);
			}, 200);
		},
		async loadData(pullScroll) {
			const data = {
				uid: uni.getStorageSync('uid'),
				pageNo: pullScroll.page,
				pageSize: '10'
			};
			const res = await this.$request('user/msg-list', data, { showLoading: true });
			if (pullScroll.page == 1) this.dataList = [];
			if (res.result == 0) {
				this.dataList = this.dataList.concat(res.data.list);
				pullScroll.endByPage(Math.ceil(res.data.count / 10), res.data.list);
			} else {
				this.$util.msg(res.resultNote);
			}
		}
	}
};
</script>
<style scoped lang="scss">
.mes-con {
	margin: 0 auto;
	padding: 20rpx;
}
.item {
	padding: 40rpx 0;
	border-bottom: 1px solid #e7e7e7;
}
.item:last-child {
	border-bottom: none;
}
.item-left-icon {
	position: relative;
	width: 76rpx;
	height: 76rpx;
	margin-right: 20rpx;
}
.left-icon {
	width: 76rpx;
	height: 76rpx;
}
.isRead {
	position: absolute;
	top: 0;
	right: 6rpx;
	width: 14rpx;
	height: 14rpx;
	background: #ff5656;
	border-radius: 50%;
}
.item-title {
	font-size: 34upx;
	font-family: PingFang SC;
	font-weight: 500;
	color: #000000;
	max-width:340upx;
}
.item-txt {
	font-size: 24upx;
	font-family: PingFang SC;
	font-weight: 500;
	color: #333333;
	padding-top: 10upx;
}
.item-right {
	font-size: 24rpx;
	font-family: PingFang SC;
	font-weight: 500;
	color: #999999;
}
</style>
